package com.imddy.spbatch001.joblistener;

import com.imddy.spbatch001.entity.BlogInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ItemWriteListener;
import org.springframework.batch.item.Chunk;

/**
 * @Author imddy
 * Description: 写入监听器
 */
public class MyWriteListener implements ItemWriteListener<BlogInfo> {
    private static final Logger log = LoggerFactory.getLogger(MyWriteListener.class);


    @Override
    public void beforeWrite(Chunk<? extends BlogInfo> chunk) {
        log.info("beforeWrite");
    }


    @Override
    public void afterWrite(Chunk<? extends BlogInfo> chunk) {
        log.info("afterWrite");
    }


    @Override
    public void onWriteError(Exception exception, Chunk<? extends BlogInfo> chunk) {
        log.error("onWriteError");
        log.error(exception.getMessage());
    }

}
